/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BusinessLogic;

import java.util.Vector;
import javax.swing.table.TableModel;

/**
 *
 * @author MrToan
 */
public class AdminFunction {

    DataAccess.AdminFunction Function= new DataAccess.AdminFunction();
    public String updateInfor_BL(String UID, String Name, String Phone, String Email, String Address) {
        int respond = Function.updateDateInfor_DA(UID,Name,Phone,Email,Address);
        String message;
        if(respond==1)
        {
            message="Update Successful!";
        }else{
            message = "Update Failed!";
        }
        return message;
    }

    
    public int Add_New_User(String UID,String RID,String Name,String UserName,String Pass,String Phone,String Email,String Address,int Status)
    {
        int Add_Success=Function.AddUser(UID, RID, Name, UserName, Pass, Phone, Email, Address, Status);
        
        return Add_Success;
    }

    public TableModel UserTable()
    {
        TableModel TB=Function.getUserTableValue();
        return TB;
    }

    public int UpdateUser(String UID,String RID,int Status)
    {
        int UpdateSuccess=Function.UpdateUser(UID, RID, Status);
        return UpdateSuccess;
    }

    public String getRID(String RName)
    {
        String RID=Function.getRID(RName);
        return RID;
    }

    public int getPer(String RID)
    {
        int per = Function.getPer(RID);
        return  per;
    }

    public Vector getCategory()
    {
        Vector Cate=Function.getCate();
        return Cate;
    }

    public int getCateID(String CName)
    {
        int CID=Function.getCateID(CName);
        return CID;
    }
    
    public TableModel ItemTable()
    {
        TableModel TB=Function.getItemTableValue();
        return TB;
    }

    public int Add_Item(String IID, int ICate, String IName, String IUnit, int IQuantity, float IPrice, int IStatus)
    {
        int InsertSuccess=Function.Add_Items(IID,ICate,IName,IUnit,IQuantity,IPrice,IStatus);
        return InsertSuccess;
    }

    public int UpdateItem(String IID, int ICate, String IName, String IUnit, int IQuantity, float IPrice)
    {
        int UpdateSuccess=Function.UpdateItem(IID,ICate,IName,IUnit,IQuantity,IPrice);
        return UpdateSuccess;
    }

    public int DeleteItem(String IID)
    {
        int DeleteSuccess=Function.DeleteItem(IID);
        return DeleteSuccess;
    }

    public int GenerateCID()
    {
        int CID=Function.GenerateCateID();
        return CID;
    }

    public int AddCate(String CName,int CStatus)
    {
        int AddSuccess=Function.AddCategory(CName,CStatus);
        return AddSuccess;
    }

    public TableModel CateTable()
    {
        TableModel TB=Function.getCateTableValue();
        return TB;
    }

     public int UpdateCate(int CID,String CName)
    {
        int UpdateSuccess=Function.UpdateCate(CID,CName);
        return UpdateSuccess;
    }

     public int DeleteCate(int CID)
    {
        int DeleteSuccess=Function.DeleteCate(CID);
        return DeleteSuccess;
    }

    public String changePass_BL(String userID, String NewPass) {
        int respond = Function.changePass_DA(userID,NewPass);
        String message;
        if(respond!=0){
            message="Change Password Successful !";
        }else{
            message = "Change Password Failed";
        }
        return message;
    }

}
